Basic Tasks

Index preparation is a process involving the following steps:
  1. Placing index commands in the document source, which presumably comprises multiple files. An index command takes a single argument: the key to be indexed.
  2. Creating a raw index file whose entries each consists of two arguments: the index key and the page on which the index command appears.
  3. Processing the raw index file. Here, all index keys are sorted alphabetically. Page numbers under the same key are merged and successive numbers may be collected into intervals (e.g., 1, 2, 3, 4, 5 is replaced by 1-5). Subitems within an entry, if any, are properly handled.
  4. Formatting the processed index. The result is the actual index.
The idea is illustrated in Figure 1, where roman capitals I–IV marking the edges correspond to the four steps here. This procedure is a highly sequential, for the input to one step depends upon the result from the previous one.

Figure 2 exemplifies a stepwise development of the process. In LATEX and TEX, all commands begin with a backslash (\). Figure 2.a shows some occurrences of index commands (\index) in the document source, with corresponding pages listed on the left. The page number is not part of the source file since at file-preparation time, it is unclear on which page a given textual material will eventually appear. Figure 2.a includes these numbers just to indicate that ultimately these entries would appear on those pages. Figure 2.b shows a raw index file generated by LATEX. After running through the index processor, it becomes an alphabetized index with commands specifying a particular output appearance (Figure 2.c). The result after formatting is shown in Figure 2.d.

Figure: The stepwise development of index processing. This example is specified in LATEX. (a) Top Left: Occurrences of index commands in the document source. Note that page numbers are unknown at the time of input when a source-based formatter like LATEX is used. Page numbers are included here simply to illustrate where each instance will occur. (b) Top Right: raw index file generated by LATEX. (c) Bottom Left: alphabetized index file. (d) Bottom Right: formatted final index.
      
 Page iv: \index{alpha}  
 Page 1: \index{alpha}  
 Page 2: \index{alpha}  
 Page 3: \index{alpha}  
 Page 11: \index{alphabeta|see{beta}}  
 Page 14: \index{alpha@{\it alpha\/}}  
   \index{beta|bold}  
 Page 22: \index{alpha!beta!gamma}  
 Page 38: \index{alpha!delta}  
      



\indexentry{alpha}{iv}
\indexentry{alpha}{1}
\indexentry{alpha}{2}
\indexentry{alpha}{3}
\indexentry{alphabeta|see{beta}}{11}
\indexentry{alpha@{\it alpha\/}}{14}
\indexentry{beta|bold}{14}
\indexentry{alpha!beta!gamma}{22}
\indexentry{alpha!delta}{38}

      
 \begin{theindex}    
      
 \item alpha, iv, 1-3    
  \subitem beta    
  \subsubitem gamma, 22    
  \subitem delta, 38    
 \item {\it alpha\/}, 14    
 \item alphabeta, \see{beta}{11}    
      
 \indexspace    
      
 \item beta, \bold{14}    
      
 \end{theindex}    



alpha, iv, 1–3
beta
gamma, 22
delta, 38
alpha, 14
alphabeta, see beta

beta, 14

Based on the example given in Figure 2, these four steps are explained below, where Steps I and III are further expanded in subsequent sections. Issues involved in Steps II and IV are less complex and are covered only in this section.



Subsections